package com.caesar.Date.third;

import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @author caesar
 * @date 2025/7/15
 * @Description:本地日期或时间
 * @apiNote
 */
public class TestLocalDateTime {
    @Test
    public void test1(){
        //本地日期,当天日期
        LocalDate ld = LocalDate.now();
        System.out.println(ld);
        //2025-07-15
    }

    @Test
    public void test2(){
        //自己设置年月日
        LocalDate ld = LocalDate.of(2000, 7, 16);
        System.out.println(ld);
    }

    @Test
    public void test3(){
        //本地时间，当下具体时间点
        LocalTime lt = LocalTime.now();
        System.out.println(lt);
        //10:24:08.984475   时 分 秒 毫秒
    }

    @Test
    public void test4(){
        //自己设置时间，时分秒
        LocalTime lt = LocalTime.of(9, 50, 00);
        System.out.println(lt);//09:50
    }

    @Test
    public void test5(){
        //本地日期+时间
        LocalDateTime ldt = LocalDateTime.now();
        System.out.println(ldt);

        LocalDateTime dateTime = LocalDateTime.of(2025, 7, 15, 9, 50);
        System.out.println(dateTime);
        /*
        2025-07-15T09:33:41.323818300
        2025-07-15T09:50
         */
    }
}
